[BEGINNER] Javascript Pop Ups
Posted
by
user566312
on Stack Overflow
See other posts from Stack Overflow
or by user566312
Published on 2011-01-07T02:00:41Z
Indexed on
2011/01/07
3:53 UTC
Read the original article
Hit count: 298
Hey All,
My boss has asked for a page that will not change to have two timed pop ups load. I have found code and edited it to what I had thought it should do, but it is only loading the last onLoad event. I am a designer and I have helped with making webpages, but Javascript is so far outside of what I can understand. I have already learned how to use the single pop up and spent a whiiile learning the timeouts, but I cannot seem to get it to work with multiple popup functions. If you have a moment, would you take a look? Thank you :)
h
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>H's Page 1</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore, Editor -->
<!-- Web Site: The JavaScript Source -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
closetime = 3; // Close window after __ number of seconds?
// 0 = do not close, anything else = number of seconds
function Start1(URL, WIDTH, HEIGHT) {
windowprops = "left=50,top=50,width=" + WIDTH + ",height=" + HEIGHT;
preview = window.open(URL, "preview", windowprops);
if (closetime) setTimeout("preview.close();", closetime*1000);
}
function doPopup1() {
url = "http://www.google.com";
width = 1680; // width of window in pixels
height = 1050; // height of window in pixels
delay = 10; // time in seconds before popup opens
timer = setTimeout("Start1(url, width, height)", delay*1000);
}
closetime = 3; // Close window after __ number of seconds?
function Start2(URL, WIDTH, HEIGHT) {
windowprops = "left=50,top=50,width=" + WIDTH + ",height=" + HEIGHT;
preview = window.open(URL, "preview", windowprops);
if (closetime) setTimeout("preview.close();", closetime*1000);
}
function doPopup2() {
url = "http://www.yahoo.com";
width = 1680; // width of window in pixels
height = 1050; // height of window in pixels
delay = 5; // time in seconds before popup opens
timer = setTimeout("Start2(url, width, height)", delay*1000);
}
// End -->
</script>
<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
<!-- Script Size: 1.27 KB -->
</head>
<body OnLoad="doPopup1(); doPopup2();">
<p>My page text.</p>
<p>My page text.</p>
<p>My page text.</p>
<p>My page text.</p>
</body>
</html>
© Stack Overflow or respective owner